package net.asgarli.abalone.model;

/**
 * Represents the Attachment. Attachment data structure is used for large amount
 * of data, that is stored and retrieved separately from main data structures.
 * 
 * @param <T>
 *            The type of value of attachment.
 * @author Elchin
 */
public class Attachment<T> {

    /** ID used in external data store. */
    private Long externalID;

    /** ID used internally by UnitEntries. */
    private Long internalID;

    private T value;

    //
    // ************************* GENERATED *************************
    // ************************* Getters and Setters ***************
    //
    public Long getExternalID() {
        return externalID;
    }

    public void setExternalID(Long externalID) {
        this.externalID = externalID;
    }

    public Long getInternalID() {
        return internalID;
    }

    public void setInternalID(Long internalID) {
        this.internalID = internalID;
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    //
    // ************************* GENERATED *************************
    //
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Attachment [externalID=");
        builder.append(externalID);
        builder.append(", internalID=");
        builder.append(internalID);
        builder.append(", value=");
        builder.append(value);
        builder.append("]");
        return builder.toString();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((externalID == null) ? 0 : externalID.hashCode());
        result = prime * result + ((internalID == null) ? 0 : internalID.hashCode());
        result = prime * result + ((value == null) ? 0 : value.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        @SuppressWarnings("rawtypes")
        Attachment other = (Attachment) obj;
        if (externalID == null) {
            if (other.externalID != null) return false;
        } else if (!externalID.equals(other.externalID)) return false;
        if (internalID == null) {
            if (other.internalID != null) return false;
        } else if (!internalID.equals(other.internalID)) return false;
        if (value == null) {
            if (other.value != null) return false;
        } else if (!value.equals(other.value)) return false;
        return true;
    }
}
